package com.sun.androidexerciseproject.widget.activity.ui;

import android.net.Uri;
import android.support.v4.view.ViewPager;

import com.sun.androidexerciseproject.widget.R;
import com.sun.androidexerciseproject.widget.adapter.FragmentStateAdapter;
import com.sun.androidexerciseproject.widget.base.BaseFragment;
import com.sun.androidexerciseproject.widget.base.BaseFragmentActivity;
import com.sun.androidexerciseproject.widget.fragment.FourFragment;
import com.sun.androidexerciseproject.widget.fragment.OneFragment;
import com.sun.androidexerciseproject.widget.fragment.ThreeFragment;
import com.sun.androidexerciseproject.widget.fragment.TwoFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Steven on 2016/12/27 0027.
 */

public class FragmentTestActivity extends BaseFragmentActivity implements BaseFragment.OnFragmentInteractionListener {
    private ViewPager mViewPager;
    private List<BaseFragment> mBaseFragmentList;
    private FragmentStateAdapter mFragmentAdapter;

    @Override
    public void onFragmentInteraction(Uri uri) {

    }


    @Override
    protected void initView() {
        mViewPager = (ViewPager) findViewById(R.id.view_pager);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_fragment_test;
    }

    @Override
    protected void initData() {
        mBaseFragmentList = new ArrayList<>();
        OneFragment oneFragment = new OneFragment();
        TwoFragment twoFragment = new TwoFragment();
        ThreeFragment threeFragment = new ThreeFragment();
        FourFragment fourFragment = new FourFragment();
        mBaseFragmentList.add(oneFragment);
        mBaseFragmentList.add(twoFragment);
        mBaseFragmentList.add(threeFragment);
        mBaseFragmentList.add(fourFragment);
        mFragmentAdapter = new FragmentStateAdapter(getSupportFragmentManager(), mBaseFragmentList);
        mViewPager.setAdapter(mFragmentAdapter);
        mViewPager.setCurrentItem(2);
    }
}
